package com.yksj.healthtalk.entity;

import java.io.Serializable;
import java.util.ArrayList;
import java.util.List;

import org.json.JSONArray;
import org.json.JSONException;
import org.json.JSONObject;

import android.os.Parcel;
import android.os.Parcelable;

/**
 * 服务内容实体
 * @author Administrator
 *
 */
public class DoctorServiceContentEntity implements Parcelable,Serializable{
	private String SERVICE_CONTENT_ID ;//医生服务内容ID
	private String SERVICE_CONTENT  ;//服务服务内容名称
	private String SERVICE_DESC  ;//服务服务内容描述
	private String ISSELECT  ;//1为打钩0为空
	private String SERVICE_TYPE ;//为System的不可以删除
	private boolean isContentChange=false;//内容是否延伸
	private String NECESSARY_FLAG;
	
	
	public String getNECESSARY_FLAG() {
		return NECESSARY_FLAG;
	}
	public void setNECESSARY_FLAG(String nECESSARY_FLAG) {
		NECESSARY_FLAG = nECESSARY_FLAG;
	}
	public boolean isContentChange() {
		return isContentChange;
	}
	public void setContentChange(boolean isContentChange) {
		this.isContentChange = isContentChange;
	}
	public String getSERVICE_CONTENT_ID() {
		return SERVICE_CONTENT_ID;
	}
	public void setSERVICE_CONTENT_ID(String sERVICE_CONTENT_ID) {
		SERVICE_CONTENT_ID = sERVICE_CONTENT_ID;
	}
	public String getSERVICE_CONTENT() {
		return SERVICE_CONTENT;
	}
	public void setSERVICE_CONTENT(String sERVICE_CONTENT) {
		SERVICE_CONTENT = sERVICE_CONTENT;
	}
	public String getSERVICE_DESC() {
		return SERVICE_DESC;
	}
	public void setSERVICE_DESC(String sERVICE_DESC) {
		SERVICE_DESC = sERVICE_DESC;
	}
	public String getISSELECT() {
		return ISSELECT;
	}
	public void setISSELECT(String iSSELECT) {
		ISSELECT = iSSELECT;
	}
	public String getSERVICE_TYPE() {
		return SERVICE_TYPE;
	}
	public void setSERVICE_TYPE(String sERVICE_TYPE) {
		SERVICE_TYPE = sERVICE_TYPE;
	}
	public static List<DoctorServiceContentEntity> parsoToList(String content) {
		List<DoctorServiceContentEntity> entities=new ArrayList<DoctorServiceContentEntity>();
		try {
			JSONArray array=new JSONArray(content);
			for (int i = 0; i < array.length(); i++) {
				DoctorServiceContentEntity entity=new DoctorServiceContentEntity();
				JSONObject object=(JSONObject) array.get(i);
				entity.setISSELECT(object.optString("ISSELECT"));
				entity.setSERVICE_CONTENT(object.optString("SERVICE_CONTENT"));
				entity.setSERVICE_CONTENT_ID(object.optString("SERVICE_CONTENT_ID"));
				entity.setSERVICE_DESC(object.optString("SERVICE_DESC"));
				entity.setSERVICE_TYPE(object.optString("SERVICE_TYPE"));
				entity.setNECESSARY_FLAG(object.optString("NECESSARY_FLAG",""));
				entities.add(entity);
			}
			return entities;
		} catch (JSONException e) {
			return null;
		}
	}
	
	@Override
	public int describeContents() {
		return 0;
	}
	
	@Override
	public void writeToParcel(Parcel dest, int flags) {
		dest.writeString(this.ISSELECT);  
		dest.writeString(this.SERVICE_CONTENT);  
		dest.writeString(this.SERVICE_CONTENT_ID);  
		dest.writeString(this.SERVICE_DESC);  
		dest.writeString(this.SERVICE_TYPE);
	}
	
	 public static final Parcelable.Creator<DoctorServiceContentEntity> CREATOR = new Parcelable.Creator<DoctorServiceContentEntity>() {   
		//重写Creator
		  
		        @Override  
		        public DoctorServiceContentEntity createFromParcel(Parcel source) {   
		        	DoctorServiceContentEntity p = new DoctorServiceContentEntity(); 
		        	p.ISSELECT=source.readString();
		        	p.SERVICE_CONTENT=source.readString();
		        	p.SERVICE_CONTENT_ID=source.readString();
		        	p.SERVICE_DESC=source.readString();
		        	p.SERVICE_TYPE=source.readString();
		            return p;   
		        }   
		  
		        @Override  
		        public DoctorServiceContentEntity[] newArray(int size) {   
		            return new DoctorServiceContentEntity[size];   
		        }   
		    }; 
	
}
